// {% load static %}
function progress(){
    //每上传一个文件，添加一个进度条
    var addhtml = " <div id=\"backname\" style=\"color: orangered\" class=\"col-sm-9\">文件格式化进度</div>\n" +
        "<div id=\"backurl\" style=\"display: none\"></div>\n" +
        "<div class=\"col-sm-2\" style=\"color: orangered\">处理进度:</div>\n" +
        "<div style=\"color: #2aabd2\" id=\"percentage\" class=\"col-sm-1\">0%</div>\n" +
        " <div class=\"clearfix\"></div>\n" +
        "<div class=\"progress progress-small\" >\n" +
        "<div id=\"percentagebar\" style=\"width:0%;\" class=\"progress-bar progress-bar-success \"></div>\n" +
        " </div> ";
    $("#progress_ajax").empty();//每次点击上传按钮，把所有的进度条清空


    // var newbackname = "backname" + "文件格式化进度";//文件名
    var newp = "percentage" ;//每个文件的进度
    var newpbar = "percentagebar" + "进度";//每个进度条的名字

    $("#progress_ajax").append(addhtml);
    // $("#backname").attr('id', newbackname);
    $("#percentage").attr('id', newp);
    $("#percentagebar").attr('id', newpbar);


    var sitv = setInterval(function(){
        var prog_url =  "/Tool/progress"                  // prog_url指请求进度的url，后面会在django中设置
        $.getJSON(prog_url, function(res){
            if(res<100) {
                percentage =res;
                var now_percentage = percentage + "%";
                $("#" + newp).html(now_percentage);
                $("#" + newpbar).css({"width": now_percentage});
                // $("#" + newbackname).html(myfilename);
            }else if(res==100){
                //到100停止发送
                clearInterval(sitv)
                // alert("！")
            }

        });
    }, 100);                                 // 每1.8秒查询一次后台进度

}
